<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>用户管理添加 - 春天集团</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/asserts/css/ksd.css" media="all">
  <style>
    .layui-card-header{font-size:18px;font-weight: bold}
     [v-cloak]{display: none}
  </style>
</head>
<body>
<div class="layui-fluid" id="app" v-cloak>
<div class="layui-containerx" style="padding: 30px;background: #fff;">
  <div class="layui-row layui-col-space15">
  <div class="layui-col-md12">
    <div class="layui-card" style="overflow: hidden;padding-bottom: 20px;">
      <h3 class="fl fw fz24">用户{{id?'编辑':'添加'}}</h3>
      <div class="layui-input-blockc fr" >
        <a href="/admin/user/list"  class="layui-btn layui-btn-primary">返回</a>
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      </div>
    </div>

    <input type="hidden" v-model="user.id">
     <div class="layui-card">
       <div class="layui-card-header">用户密码</div>
       <div class="layui-card-body layui-row layui-col-space10">
         <div class="layui-col-md12">
           <input type="text" name="password" placeholder="请输入用户密码" maxlength="255"  v-model="user.password" autocomplete="off" class="layui-input">
         </div>
       </div>
     </div>
     <div class="layui-card">
       <div class="layui-card-header">权限</div>
       <div class="layui-card-body layui-row layui-col-space10">
         <div class="layui-col-md12">
           <input type="text" name="role" placeholder="请输入权限" maxlength="255"  v-model="user.role" autocomplete="off" class="layui-input">
         </div>
       </div>
     </div>
    <div class="layui-card layui-form" >
      <div class="layui-card-header">用户头像</div>
      <div class="layui-card-body layui-row layui-col-space10">
        <div class="layui-col-md12">
          <input type="text"  placeholder="请上传产品封面（尺寸：293 * 375）" v-model="user.avatar" autocomplete="off" class="layui-input">
          <input id="avatar" type="file" onchange="submit2('avatar','avatar')" style="position: absolute;top:15px;right:10px;"/>
          <span class="ref fz12 pr tp2" style="color: red;">（尺寸：293 * 375）</span>
        </div>
        <div class="layui-col-12">
          <img :src="user.cover" style="width: 200px" alt="">
        </div>
      </div>
    </div>
     <div class="layui-card">
       <div class="layui-card-header">性别</div>
       <div class="layui-card-body layui-row layui-col-space10">
         <div class="layui-col-md12">
           <input type="text" name="sex" placeholder="请输入性别" maxlength="255"  v-model="user.sex" autocomplete="off" class="layui-input">
         </div>
       </div>
     </div>
    <div class="layui-card layui-form" >
        <div class="layui-card-header">发布状态</div>
        <div class="layui-card-body layui-row layui-col-space10">
        <div class="layui-col-md12">
          <input type="radio" name="status" value="1" title="发布" checked="checked">
          <div class="layui-unselect layui-form-radio" @click="user.status = 1" :class="[user.status==1?'layui-form-radioed':'']">
            <i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
            <div>发布</div>
          </div>
          <input type="radio" name="status" value="0" title="未发布" >
          <div class="layui-unselect layui-form-radio" @click="user.status = 0" :class="[user.status==0?'layui-form-radioed':'']">
            <i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
            <div>未发布</div>
          </div>
        </div>
        </div>
    </div>
     <div class="layui-card">
       <div class="layui-card-header">微信openid</div>
       <div class="layui-card-body layui-row layui-col-space10">
         <div class="layui-col-md12">
           <input type="text" name="openid" placeholder="请输入微信openid" maxlength="255"  v-model="user.openid" autocomplete="off" class="layui-input">
         </div>
       </div>
     </div>
    <div class="layui-card" style="margin-top: 30px;text-align: center">
      <div class="layui-input-blockc">
        <button type="submit" class="layui-btn" lay-submit="" @click="saveupdate" lay-filter="demo1">立即提交</button>
        <a href="/admin/user/list"  class="layui-btn layui-btn-primary">返回</a>
      </div>
    </div>
      </div>
    </div>
    </div>
  </div>
  <script src="/asserts/js/vue.min.js"></script>
  <script src="/asserts/js/axios.min.js"></script>
  <script type="text/javascript" src="/asserts/editor/wangEditor.min.js"></script>
  <script>
      var uservue = new Vue({
        el:"#app",
        editor:null,
        data:{
 
          title:"用户管理添加",
          id:"${id!}",
          user:{status:1,cover:""}
        },
        created:function(){
         
        },
        mounted:function(){
          var that = this;
          // 編輯初始化
          if(that.id){
             that.getobj();
          }
        },
        methods:{
          // 查询数据明细
          getobj:function(){
            var that = this;
            axios.get("/admin/user/get/"+that.id).then(function(res){
              that.user = res.data.data;
               
            })
          }
          // 执行保存
          ,saveupdate:function(){
            var that = this;
            axios.post("/admin/user/saveupdate",that.user).then(function(res){
                alert("操作成功!!!");
                window.location.href = "/admin/user/list";
            });
          }

        }
      });

  </script>
</body>
</html>